/*
               File: WPLogin
        Description: Entrar
             Author: GeneXus C# Generator version 10_2_5-78484
       Generated on: 6/6/2014 9:53:5.41
       Program type: Callable routine
          Main DBMS: sqlserver
*/
using System;
using System.Collections;
using GeneXus.Utils;
using GeneXus.Resources;
using GeneXus.Application;
using GeneXus.Metadata;
using System.Data;
using System.Data.SqlClient;
using GeneXus.Data;
using com.genexus;
using GeneXus.Data.ADO;
using GeneXus.Data.NTier;
using GeneXus.Data.NTier.ADO;
using System.Runtime.Remoting;
using GeneXus.WebControls;
using GeneXus.Http;
using GeneXus.XML;
using GeneXus.Search;
using GeneXus.Encryption;
using GeneXus.Http.Client;
using System.Xml.Serialization;
using System.Data.SqlTypes;
using System.ServiceModel;
using System.Runtime.Serialization;
namespace GeneXus.Programs {
   public class wplogin : GXDataArea, System.Web.SessionState.IRequiresSessionState
   {
      public wplogin( )
      {
         context = new GxContext(  );
         DataStoreUtil.LoadDataStores( context);
         dsDefault = context.GetDataStore("Default");
         IsMain = true;
         context.SetDefaultTheme("GeneXusXEv2");
      }

      public wplogin( IGxContext context )
      {
         this.context = context;
         IsMain = false;
         dsDefault = context.GetDataStore("Default");
      }

      public void release( )
      {
      }

      public void execute( )
      {
         executePrivate();
      }

      void executePrivate( )
      {
         isStatic = false;
         webExecute();
      }

      protected override void createObjects( )
      {
         chkavIsremember = new GXCheckbox();
      }

      protected void INITWEB( )
      {
         context.SetDefaultTheme("GeneXusXEv2");
         initialize_properties( ) ;
         if ( nGotPars == 0 )
         {
            entryPointCalled = false;
            gxfirstwebparm = GetNextPar( );
            gxfirstwebparm_bkp = gxfirstwebparm;
            gxfirstwebparm = DecryptAjaxCall( gxfirstwebparm);
            if ( StringUtil.StrCmp(gxfirstwebparm, "dyncall") == 0 )
            {
               setAjaxCallMode();
               if ( ! IsValidAjaxCall( true) )
               {
                  GxWebError = 1;
                  return  ;
               }
               dyncall( GetNextPar( )) ;
               return  ;
            }
            else if ( StringUtil.StrCmp(gxfirstwebparm, "gxajaxEvt") == 0 )
            {
               setAjaxEventMode();
               if ( ! IsValidAjaxCall( true) )
               {
                  GxWebError = 1;
                  return  ;
               }
               gxfirstwebparm = GetNextPar( );
            }
            else
            {
               if ( ! IsValidAjaxCall( false) )
               {
                  GxWebError = 1;
                  return  ;
               }
               gxfirstwebparm = gxfirstwebparm_bkp;
            }
         }
      }

      public override void webExecute( )
      {
         if ( initialized == 0 )
         {
            createObjects();
            initialize();
         }
         INITWEB( ) ;
         if ( ! isAjaxCallMode( ) )
         {
            MasterPageObj = (GXMasterPage) ClassLoader.GetInstance("appmasterpage", "GeneXus.Programs.appmasterpage", new Object[] {new GxContext( context.handle, context.DataStores, context.HttpContext)});
            MasterPageObj.setDataArea(this,false);
            MasterPageObj.webExecute();
            if ( ( GxWebError == 0 ) && context.isAjaxRequest( ) )
            {
               enableOutput();
               if ( ! context.isAjaxRequest( ) )
               {
                  context.GX_webresponse.AppendHeader("Cache-Control", "max-age=0");
               }
               if ( String.IsNullOrEmpty(StringUtil.RTrim( context.wjLoc)) )
               {
                  context.GX_webresponse.AddString((String)(context.getJSONResponse( )));
               }
               else
               {
                  if ( context.isAjaxRequest( ) )
                  {
                     disableOutput();
                  }
                  RenderHtmlHeaders( ) ;
                  context.Redirect( context.wjLoc );
                  context.DispatchAjaxCommands();
               }
            }
         }
         this.cleanup();
      }

      public override short ExecuteStartEvent( )
      {
         PA072( ) ;
         gxajaxcallmode = (short)((isAjaxCallMode( ) ? 1 : 0));
         if ( ( gxajaxcallmode == 0 ) && ( GxWebError == 0 ) )
         {
            START072( ) ;
         }
         return gxajaxcallmode ;
      }

      public override void RenderHtmlHeaders( )
      {
         GxWebStd.gx_html_headers( context, 0, "", "", Form.Meta, Form.Metaequiv);
      }

      public override void RenderHtmlOpenForm( )
      {
         context.WriteHtmlText( "<title>") ;
         context.SendWebValue( Form.Caption) ;
         context.WriteHtmlTextNl( "</title>") ;
         if ( StringUtil.Len( sDynURL) > 0 )
         {
            context.WriteHtmlText( "<BASE href=\""+sDynURL+"\" />") ;
         }
         define_styles( ) ;
         if ( nGXWrapped != 1 )
         {
            MasterPageObj.master_styles();
         }
         if ( ! context.isSmartDevice( ) )
         {
            context.AddJavascriptSource("gxtimezone.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("gxgral.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("gxcfg.js", "?201466953543");
         }
         else
         {
            context.AddJavascriptSource("gxtimezone.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("gxapiSD.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("gxfxSD.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("gxhtmlSD.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("gxtypesSD.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("gxpopupSD.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("gxfrmutlSD.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("gxgridSD.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("JavaScripTableSD.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("rijndaelSD.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("gxgralSD.js", "?"+context.GetBuildNumber( 78484));
            context.AddJavascriptSource("gxcfg.js", "?"+context.GetBuildNumber( 78484));
         }
         context.AddJavascriptSource("CapsLock/CapsLockRender.js", "");
         context.WriteHtmlText( Form.Headerrawhtml) ;
         context.CloseHtmlHeader();
         FormProcess = " onkeyup=\"gx.evt.onkeyup(event)\" onkeypress=\"gx.evt.onkeypress(event,true,false)\" onkeydown=\"gx.evt.onkeypress(null,true,false)\"";
         context.WriteHtmlText( "<body") ;
         context.WriteHtmlText( " "+"class=\"Form\""+" "+" style=\"-moz-opacity:0;opacity:0;"+"background-color:"+context.BuildHTMLColor( Form.Backcolor)+";") ;
         if ( ! ( String.IsNullOrEmpty(StringUtil.RTrim( Form.Background)) ) )
         {
            context.WriteHtmlText( " background-image:url("+context.convertURL( Form.Background)+")") ;
         }
         context.WriteHtmlText( "\""+FormProcess+">") ;
         context.skipLines(1);
         context.WriteHtmlTextNl( "<form id=\"MAINFORM\" onsubmit=\"try{return gx.csv.validForm()}catch(e){return true;}\" name=\"MAINFORM\" method=\"post\" class=\"Form\" novalidate action=\""+formatLink("wplogin.aspx") +"\">") ;
         GxWebStd.gx_hidden_field( context, "_EventName", "");
         GxWebStd.gx_hidden_field( context, "_EventGridId", "");
         GxWebStd.gx_hidden_field( context, "_EventRowId", "");
      }

      public override void RenderHtmlCloseForm( )
      {
         /* Send hidden variables. */
         /* Send saved values. */
         GxWebStd.gx_hidden_field( context, "CAPSLOCK1_Attachcontrol", StringUtil.RTrim( Capslock1_Attachcontrol));
         GxWebStd.gx_hidden_field( context, "CAPSLOCK1_Attachcaption", StringUtil.RTrim( Capslock1_Attachcaption));
         GxWebStd.gx_hidden_field( context, "GX_FocusControl", GX_FocusControl);
         SendAjaxEncryptionKey();
         SendComponentObjects();
         SendServerCommands();
         SendState();
         context.WriteHtmlTextNl( "</form>") ;
         include_jscripts( ) ;
      }

      public override void RenderHtmlContent( )
      {
         gxajaxcallmode = (short)((isAjaxCallMode( ) ? 1 : 0));
         if ( ( gxajaxcallmode == 0 ) && ( GxWebError == 0 ) )
         {
            WE072( ) ;
         }
      }

      public override void DispatchEvents( )
      {
         EVT072( ) ;
      }

      public override bool HasEnterEvent( )
      {
         return true ;
      }

      public override String GetPgmname( )
      {
         return "WPLogin" ;
      }

      public override String GetPgmdesc( )
      {
         return "Entrar" ;
      }

      public override GXWebForm GetForm( )
      {
         return Form ;
      }

      public override String GetSelfLink( )
      {
         return formatLink("wplogin.aspx")  ;
      }

      protected void WB070( )
      {
         if ( context.isAjaxRequest( ) )
         {
            disableOutput();
         }
         if ( ! wbLoad )
         {
            if ( nGXWrapped == 1 )
            {
               RenderHtmlHeaders( ) ;
               RenderHtmlOpenForm( ) ;
            }
            GxWebStd.gx_msg_list( context, "", context.GX_msglist.DisplayMode, "", "", "", "false");
            wb_table1_2_072( true) ;
         }
         else
         {
            wb_table1_2_072( false) ;
         }
         return  ;
      }

      protected void wb_table1_2_072e( bool wbgen )
      {
         if ( wbgen )
         {
            context.WriteHtmlText( "<p>") ;
            /* User Defined Control */
            context.WriteHtmlText( "<div class=\"gx_usercontrol\" id=\""+"CAPSLOCK1Container"+"\"></div>") ;
            context.WriteHtmlText( "</p>") ;
         }
         wbLoad = true;
      }

      protected void START072( )
      {
         wbLoad = false;
         wbEnd = 0;
         wbStart = 0;
         Form.Meta.addItem("generator", "GeneXus C# 10_2_5-78484", 0) ;
         Form.Meta.addItem("description", "Entrar", 0) ;
         context.wjLoc = "";
         context.nUserReturn = 0;
         context.wbHandled = 0;
         if ( StringUtil.StrCmp(context.GetRequestMethod( ), "POST") == 0 )
         {
         }
         wbErr = false;
         STRUP070( ) ;
      }

      protected void WS072( )
      {
         START072( ) ;
         EVT072( ) ;
      }

      protected void EVT072( )
      {
         if ( StringUtil.StrCmp(context.GetRequestMethod( ), "POST") == 0 )
         {
            if ( String.IsNullOrEmpty(StringUtil.RTrim( context.wjLoc)) && ( context.nUserReturn != 1 ) && ! wbErr )
            {
               /* Read Web Panel buttons. */
               sEvt = cgiGet( "_EventName");
               EvtGridId = cgiGet( "_EventGridId");
               EvtRowId = cgiGet( "_EventRowId");
               if ( StringUtil.Len( sEvt) > 0 )
               {
                  sEvtType = StringUtil.Left( sEvt, 1);
                  sEvt = StringUtil.Right( sEvt, (short)(StringUtil.Len( sEvt)-1));
                  if ( StringUtil.StrCmp(sEvtType, "M") != 0 )
                  {
                     if ( StringUtil.StrCmp(sEvtType, "E") == 0 )
                     {
                        sEvtType = StringUtil.Right( sEvt, 1);
                        if ( StringUtil.StrCmp(sEvtType, ".") == 0 )
                        {
                           sEvt = StringUtil.Left( sEvt, (short)(StringUtil.Len( sEvt)-1));
                           if ( StringUtil.StrCmp(sEvt, "RFR") == 0 )
                           {
                              context.wbHandled = 1;
                              dynload_actions( ) ;
                           }
                           else if ( StringUtil.StrCmp(sEvt, "START") == 0 )
                           {
                              context.wbHandled = 1;
                              dynload_actions( ) ;
                              /* Execute user event: E11072 */
                              E11072 ();
                           }
                           else if ( StringUtil.StrCmp(sEvt, "ENTER") == 0 )
                           {
                              context.wbHandled = 1;
                              if ( ! wbErr )
                              {
                                 Rfr0gs = false;
                                 if ( ! Rfr0gs )
                                 {
                                    /* Execute user event: E12072 */
                                    E12072 ();
                                 }
                                 dynload_actions( ) ;
                              }
                           }
                           else if ( StringUtil.StrCmp(sEvt, "LOAD") == 0 )
                           {
                              context.wbHandled = 1;
                              dynload_actions( ) ;
                              /* Execute user event: E13072 */
                              E13072 ();
                              /* No code required for Cancel button. It is implemented as the Reset button. */
                           }
                           else if ( StringUtil.StrCmp(sEvt, "LSCR") == 0 )
                           {
                              context.wbHandled = 1;
                              dynload_actions( ) ;
                              dynload_actions( ) ;
                           }
                        }
                        else
                        {
                        }
                     }
                     context.wbHandled = 1;
                  }
               }
            }
         }
      }

      protected void WE072( )
      {
         if ( ! GxWebStd.gx_redirect( context) )
         {
            Rfr0gs = true;
            Refresh( ) ;
            if ( ! GxWebStd.gx_redirect( context) )
            {
               if ( nGXWrapped == 1 )
               {
                  RenderHtmlCloseForm( ) ;
               }
            }
         }
      }

      protected void PA072( )
      {
         if ( nDonePA == 0 )
         {
            if ( String.IsNullOrEmpty(StringUtil.RTrim( context.GetCookie( "GX_SESSION_ID"))) )
            {
               gxcookieaux = context.SetCookie( "GX_SESSION_ID", Crypto.Encrypt64( Crypto.GetEncryptionKey( ), Crypto.GetServerKey( )), "", (DateTime)(DateTime.MinValue), "", 0);
            }
            GXKey = Crypto.Decrypt64( context.GetCookie( "GX_SESSION_ID"), Crypto.GetServerKey( ));
            chkavIsremember.Name = "vISREMEMBER";
            chkavIsremember.WebTags = "";
            chkavIsremember.Caption = "";
            context.httpAjaxContext.ajax_rsp_assign_prop("", false, chkavIsremember_Internalname, "Caption", chkavIsremember.Caption);
            chkavIsremember.CheckedValue = "false";
            if ( ! context.isAjaxRequest( ) )
            {
               GX_FocusControl = edtavUsercid_Internalname;
               context.httpAjaxContext.ajax_rsp_assign_attri("", false, "GX_FocusControl", GX_FocusControl);
            }
            nDonePA = 1;
         }
      }

      protected void dynload_actions( )
      {
         /* End function dynload_actions */
      }

      protected void Refresh( )
      {
         RF072( ) ;
         /* End function Refresh */
      }

      protected void RF072( )
      {
         if ( String.IsNullOrEmpty(StringUtil.RTrim( context.wjLoc)) && ( context.nUserReturn != 1 ) )
         {
            /* Execute user event: E13072 */
            E13072 ();
            WB070( ) ;
         }
      }

      protected void STRUP070( )
      {
         /* Before Start, stand alone formulas. */
         Gx_date = DateTimeUtil.Today( context);
         context.Gx_err = 0;
         /* Execute Start event if defined. */
         context.wbGlbDoneStart = 0;
         /* Execute user event: E11072 */
         E11072 ();
         context.wbGlbDoneStart = 1;
         /* After Start, stand alone formulas. */
         if ( StringUtil.StrCmp(context.GetRequestMethod( ), "POST") == 0 )
         {
            /* Read saved SDTs. */
            /* Read variables values. */
            if ( ( ( context.localUtil.CToN( cgiGet( edtavUsercid_Internalname), ".", ",") < Convert.ToDecimal( 0 )) ) || ( ( context.localUtil.CToN( cgiGet( edtavUsercid_Internalname), ".", ",") > Convert.ToDecimal( 999999 )) ) )
            {
               GX_msglist.addItem(context.GetMessage( "GXM_badnum", ""), 1, "vUSERCID");
               GX_FocusControl = edtavUsercid_Internalname;
               context.httpAjaxContext.ajax_rsp_assign_attri("", false, "GX_FocusControl", GX_FocusControl);
               wbErr = true;
               AV9UserCID = 0;
               context.httpAjaxContext.ajax_rsp_assign_attri("", false, "AV9UserCID", StringUtil.LTrim( StringUtil.Str( (decimal)(AV9UserCID), 6, 0)));
            }
            else
            {
               AV9UserCID = (int)(context.localUtil.CToN( cgiGet( edtavUsercid_Internalname), ".", ","));
               context.httpAjaxContext.ajax_rsp_assign_attri("", false, "AV9UserCID", StringUtil.LTrim( StringUtil.Str( (decimal)(AV9UserCID), 6, 0)));
            }
            AV10UserSenha = cgiGet( edtavUsersenha_Internalname);
            context.httpAjaxContext.ajax_rsp_assign_attri("", false, "AV10UserSenha", AV10UserSenha);
            AV7isRemember = StringUtil.StrToBool( cgiGet( chkavIsremember_Internalname));
            context.httpAjaxContext.ajax_rsp_assign_attri("", false, "AV7isRemember", StringUtil.BoolToStr( AV7isRemember));
            /* Read saved values. */
            Capslock1_Attachcontrol = cgiGet( "CAPSLOCK1_Attachcontrol");
            Capslock1_Attachcaption = cgiGet( "CAPSLOCK1_Attachcaption");
            /* Read subfile selected row values. */
            /* Read hidden variables. */
            GXKey = Crypto.Decrypt64( context.GetCookie( "GX_SESSION_ID"), Crypto.GetServerKey( ));
         }
         else
         {
            dynload_actions( ) ;
         }
      }

      protected void GXStart( )
      {
         /* Execute user event: E11072 */
         E11072 ();
         if (returnInSub) return;
      }

      protected void E11072( )
      {
         /* Start Routine */
         lblTextblock5_Caption = "";
         context.httpAjaxContext.ajax_rsp_assign_prop("", false, lblTextblock5_Internalname, "Caption", lblTextblock5_Caption);
         Capslock1_Attachcontrol = edtavUsersenha_Internalname;
         context.httpAjaxContext.ajax_rsp_assign_uc_prop("", false, Capslock1_Internalname, "AttachControl", Capslock1_Attachcontrol);
         Capslock1_Attachcaption = lblTextblock5_Internalname;
         context.httpAjaxContext.ajax_rsp_assign_uc_prop("", false, Capslock1_Internalname, "AttachCaption", Capslock1_Attachcaption);
         AV8Login = context.GetCookie( "LoginDemolayCookie");
         AV10UserSenha = context.GetCookie( "PasswordDemolayCookie");
         context.httpAjaxContext.ajax_rsp_assign_attri("", false, "AV10UserSenha", AV10UserSenha);
         AV9UserCID = (int)(NumberUtil.Val( AV8Login, "."));
         context.httpAjaxContext.ajax_rsp_assign_attri("", false, "AV9UserCID", StringUtil.LTrim( StringUtil.Str( (decimal)(AV9UserCID), 6, 0)));
         AV13UserId = (long)(NumberUtil.Val( AV11websession.Get("DemolayUserId"), "."));
         AV12Nivel = AV11websession.Get("DemolayUserNivel");
         if ( ! (0==AV13UserId) && ! String.IsNullOrEmpty(StringUtil.RTrim( AV12Nivel)) )
         {
            context.wjLoc = formatLink("wpstartpage.aspx") ;
            context.wjLocDisableFrm = 1;
         }
         if ( ! (0==AV9UserCID) && ! String.IsNullOrEmpty(StringUtil.RTrim( AV10UserSenha)) )
         {
            /* Execute user subroutine: S112 */
            S112 ();
            if (returnInSub) return;
         }
      }

      public void GXEnter( )
      {
         /* Execute user event: E12072 */
         E12072 ();
         if (returnInSub) return;
      }

      protected void E12072( )
      {
         /* Enter Routine */
         /* Execute user subroutine: S112 */
         S112 ();
         if (returnInSub) return;
      }

      protected void S112( )
      {
         /* 'LOGIN' Routine */
         /* Using cursor H00072 */
         pr_default.execute(0, new Object[] {AV9UserCID});
         while ( (pr_default.getStatus(0) != 101) )
         {
            A1UserCID = H00072_A1UserCID[0];
            context.httpAjaxContext.ajax_rsp_assign_attri("", false, "A1UserCID", StringUtil.LTrim( StringUtil.Str( (decimal)(A1UserCID), 6, 0)));
            A18UserSenhaKey = H00072_A18UserSenhaKey[0];
            context.httpAjaxContext.ajax_rsp_assign_attri("", false, "A18UserSenhaKey", A18UserSenhaKey);
            A17UserSenha = H00072_A17UserSenha[0];
            context.httpAjaxContext.ajax_rsp_assign_attri("", false, "A17UserSenha", A17UserSenha);
            A21UserNivel = H00072_A21UserNivel[0];
            context.httpAjaxContext.ajax_rsp_assign_attri("", false, "A21UserNivel", A21UserNivel);
            A43UserId = H00072_A43UserId[0];
            context.httpAjaxContext.ajax_rsp_assign_attri("", false, "A43UserId", StringUtil.LTrim( StringUtil.Str( (decimal)(A43UserId), 15, 0)));
            if ( StringUtil.StrCmp(Crypto.Decrypt64( A17UserSenha, A18UserSenhaKey), AV10UserSenha) == 0 )
            {
               AV11websession.Set("DemolayUserNivel", A21UserNivel);
               AV11websession.Set("DemolayUserId", StringUtil.Str( (decimal)(A43UserId), 15, 0));
               if ( AV7isRemember )
               {
                  AV5CookieLogin = context.SetCookie( "LoginDemolayCookie", StringUtil.Str( (decimal)(AV9UserCID), 6, 0), "", DateTimeUtil.AddYr( Gx_date, 99), "", 0);
                  AV6CookiePassword = context.SetCookie( "PasswordDemolayCookie", AV10UserSenha, "", DateTimeUtil.AddYr( Gx_date, 99), "", 0);
               }
               context.wjLoc = formatLink("wpstartpage.aspx") ;
               context.wjLocDisableFrm = 1;
            }
            else
            {
               context.PopUp(formatLink("wppopup.aspx") + "?" + UrlEncode(StringUtil.RTrim("CID ou Senha incorretos.")), new Object[] {""});
            }
            pr_default.readNext(0);
         }
         pr_default.close(0);
      }

      protected void nextLoad( )
      {
      }

      protected void E13072( )
      {
         /* Load Routine */
      }

      protected void wb_table1_2_072( bool wbgen )
      {
         if ( wbgen )
         {
            /* Table start */
            sStyleString = "";
            sStyleString = sStyleString + "background-color: " + context.BuildHTMLColor( (int)(0xF4F4F4)) + ";";
            sStyleString = sStyleString + "border:" + StringUtil.Str( (decimal)(2), 3, 0) + "px solid;";
            if ( StringUtil.StrCmp(context.BuildHTMLColor( (int)(0xCCCCCC))+";", "") != 0 )
            {
               sStyleString = sStyleString + " border-color: " + context.BuildHTMLColor( (int)(0xCCCCCC)) + ";";
            }
            GxWebStd.gx_table_start( context, tblTable1_Internalname, tblTable1_Internalname, "", "Table", 2, "", "", 1, 2, sStyleString, "", 0);
            context.WriteHtmlText( "<tbody>") ;
            context.WriteHtmlText( "<tr>") ;
            context.WriteHtmlText( "<td class=\"Padding10px\"  style=\"height:7px\">") ;
            wb_table2_5_072( true) ;
         }
         else
         {
            wb_table2_5_072( false) ;
         }
         return  ;
      }

      protected void wb_table2_5_072e( bool wbgen )
      {
         if ( wbgen )
         {
            context.WriteHtmlText( "</td>") ;
            context.WriteHtmlText( "</tr>") ;
            context.WriteHtmlText( "</tbody>") ;
            /* End of table */
            context.WriteHtmlText( "</table>") ;
            wb_table1_2_072e( true) ;
         }
         else
         {
            wb_table1_2_072e( false) ;
         }
      }

      protected void wb_table2_5_072( bool wbgen )
      {
         if ( wbgen )
         {
            /* Table start */
            sStyleString = "";
            GxWebStd.gx_table_start( context, tblTable2_Internalname, tblTable2_Internalname, "", "Table", 0, "", "", 1, 2, sStyleString, "", 0);
            context.WriteHtmlText( "<tbody>") ;
            context.WriteHtmlText( "<tr>") ;
            context.WriteHtmlText( "<td colspan=\"2\" >") ;
            /* Text block */
            ClassString = "TextBlock";
            StyleString = "font-family:'Arial Narrow'; font-size:14.0pt; font-weight:bold; font-style:normal; color:#666666;";
            GxWebStd.gx_label_ctrl( context, lblTextblock1_Internalname, "Entrar", "", "", lblTextblock1_Jsonclick, "", StyleString, ClassString, 0, "", 1, 1, 0, "HLP_WPLogin.htm");
            context.WriteHtmlText( "</td>") ;
            context.WriteHtmlText( "</tr>") ;
            context.WriteHtmlText( "<tr>") ;
            context.WriteHtmlText( "<td bgcolor=\"#FFFFFF\" colspan=\"2\"  style=\"height:1px\">") ;
            context.WriteHtmlText( "</td>") ;
            context.WriteHtmlText( "</tr>") ;
            context.WriteHtmlText( "<tr>") ;
            context.WriteHtmlText( "<td colspan=\"2\"  style=\"height:7px\">") ;
            context.WriteHtmlText( "</td>") ;
            context.WriteHtmlText( "</tr>") ;
            context.WriteHtmlText( "<tr>") ;
            context.WriteHtmlText( "<td>") ;
            /* Text block */
            ClassString = "TextBlock";
            StyleString = "font-family:'Arial'; font-size:12.0pt; font-weight:normal; font-style:normal; color:#666666;";
            GxWebStd.gx_label_ctrl( context, lblTextblock2_Internalname, "CID", "", "", lblTextblock2_Jsonclick, "", StyleString, ClassString, 0, "", 1, 1, 0, "HLP_WPLogin.htm");
            context.WriteHtmlText( "</td>") ;
            context.WriteHtmlText( "<td>") ;
            /* Single line edit */
            TempTags = "  onfocus=\"gx.evt.onfocus(this, 17,'',false,'',0)\"";
            ClassString = "Attribute";
            StyleString = "font-family:'Arial'; font-size:10.0pt; font-weight:normal; font-style:normal; color:#999999;";
            GxWebStd.gx_single_line_edit( context, edtavUsercid_Internalname, StringUtil.LTrim( StringUtil.NToC( (decimal)(AV9UserCID), 6, 0, ".", "")), ((1!=0) ? StringUtil.LTrim( context.localUtil.Format( (decimal)(AV9UserCID), "ZZZZZZ")) : context.localUtil.Format( (decimal)(AV9UserCID), "ZZZZZZ")), TempTags+" onchange=\"gx.evt.onchange(this)\" "+" onblur=\""+"gx.num.valid_integer( this,',');"+";gx.evt.onblur(17);\"", "", "", "", "", "", edtavUsercid_Jsonclick, 0, ClassString, StyleString, "", 1, 1, 0, "text", "", 200, "px", 20, "px", 6, 0, 0, 0, 1, -1, 0, true, "", "left", "HLP_WPLogin.htm");
            context.WriteHtmlText( "</td>") ;
            context.WriteHtmlText( "</tr>") ;
            context.WriteHtmlText( "<tr>") ;
            context.WriteHtmlText( "<td>") ;
            /* Text block */
            ClassString = "TextBlock";
            StyleString = "font-family:'Arial'; font-size:12.0pt; font-weight:normal; font-style:normal; color:#666666;";
            GxWebStd.gx_label_ctrl( context, lblTextblock3_Internalname, "Senha", "", "", lblTextblock3_Jsonclick, "", StyleString, ClassString, 0, "", 1, 1, 0, "HLP_WPLogin.htm");
            context.WriteHtmlText( "</td>") ;
            context.WriteHtmlText( "<td>") ;
            /* Single line edit */
            TempTags = "  onfocus=\"gx.evt.onfocus(this, 22,'',false,'',0)\"";
            ClassString = "Attribute";
            StyleString = "font-family:'Arial'; font-size:10.0pt; font-weight:normal; font-style:normal; color:#999999;";
            GxWebStd.gx_single_line_edit( context, edtavUsersenha_Internalname, StringUtil.RTrim( AV10UserSenha), StringUtil.RTrim( context.localUtil.Format( AV10UserSenha, "")), TempTags+" onchange=\"gx.evt.onchange(this)\" "+" onblur=\""+""+";gx.evt.onblur(22);\"", "", "", "", "Senha", "", edtavUsersenha_Jsonclick, 0, ClassString, StyleString, "", 1, 1, 0, "text", "", 200, "px", 20, "px", 100, -1, 0, 0, 1, 1, -1, true, "", "left", "HLP_WPLogin.htm");
            context.WriteHtmlText( "</td>") ;
            context.WriteHtmlText( "</tr>") ;
            context.WriteHtmlText( "<tr>") ;
            context.WriteHtmlText( "<td style=\"vertical-align:top\">") ;
            TempTags = "  onfocus=\"gx.evt.onfocus(this, 25,'',false,'',0)\"";
            ClassString = "SpecialButtons";
            StyleString = "";
            GxWebStd.gx_button_ctrl( context, bttButton1_Internalname, "", "Entrar", bttButton1_Jsonclick, 5, "Entrar", "", StyleString, ClassString, 1, 1, "standard", "EENTER.", TempTags, "", context.GetButtonType( ), "HLP_WPLogin.htm");
            context.WriteHtmlText( "</td>") ;
            context.WriteHtmlText( "<td style=\"vertical-align:top\">") ;
            /* Check box */
            TempTags = "  onfocus=\"gx.evt.onfocus(this, 27,'',false,'',0)\"";
            ClassString = "Attribute";
            StyleString = "";
            GxWebStd.gx_checkbox_ctrl( context, chkavIsremember_Internalname, StringUtil.BoolToStr( AV7isRemember), "Lembrar-me", 1, 1, "true", "", StyleString, ClassString, TempTags+" onclick=\"gx.fn.checkboxClick(27, this, 'true', 'false');gx.evt.onchange(this);\" "+" onblur=\""+""+";gx.evt.onblur(27);\"");
            context.WriteHtmlText( "&nbsp;") ;
            /* Text block */
            ClassString = "TextBlock";
            StyleString = "font-family:'Arial'; font-size:10.0pt; font-weight:normal; font-style:normal;";
            GxWebStd.gx_label_ctrl( context, lblTextblock6_Internalname, "Lembrar-me", "", "", lblTextblock6_Jsonclick, "", StyleString, ClassString, 0, "", 1, 1, 0, "HLP_WPLogin.htm");
            context.WriteHtmlText( "<br/>") ;
            /* Text block */
            ClassString = "TextBlock";
            StyleString = "color:#FF0000;";
            GxWebStd.gx_label_ctrl( context, lblTextblock5_Internalname, lblTextblock5_Caption, "", "", lblTextblock5_Jsonclick, "", StyleString, ClassString, 0, "", 1, 1, 0, "HLP_WPLogin.htm");
            context.WriteHtmlText( "</td>") ;
            context.WriteHtmlText( "</tr>") ;
            context.WriteHtmlText( "<tr>") ;
            context.WriteHtmlText( "<td>") ;
            context.WriteHtmlText( "</td>") ;
            context.WriteHtmlText( "<td>") ;
            context.WriteHtmlText( "</td>") ;
            context.WriteHtmlText( "</tr>") ;
            context.WriteHtmlText( "</tbody>") ;
            /* End of table */
            context.WriteHtmlText( "</table>") ;
            wb_table2_5_072e( true) ;
         }
         else
         {
            wb_table2_5_072e( false) ;
         }
      }

      public override void setparameters( Object[] obj )
      {
         createObjects();
         initialize();
      }

      public override String getresponse( String sGXDynURL )
      {
         context.SetDefaultTheme("GeneXusXEv2");
         initialize_properties( ) ;
         BackMsgLst = context.GX_msglist;
         context.GX_msglist = LclMsgLst;
         sDynURL = sGXDynURL;
         nGotPars = (short)(1);
         nGXWrapped = (short)(1);
         context.SetWrapped(true);
         PA072( ) ;
         WS072( ) ;
         WE072( ) ;
         this.cleanup();
         context.SetWrapped(false);
         context.GX_msglist = BackMsgLst;
         return "";
      }

      public void responsestatic( String sGXDynURL )
      {
      }

      protected void define_styles( )
      {
         AddThemeStyleSheetFile("", context.GetTheme( )+".css", "?9522669");
         idxLst = 1;
         while ( idxLst <= Form.Jscriptsrc.Count )
         {
            context.AddJavascriptSource(StringUtil.RTrim( Form.Jscriptsrc.Item(idxLst)), "?201466953565");
            idxLst = (int)(idxLst+1);
         }
         /* End function define_styles */
      }

      protected void include_jscripts( )
      {
         context.AddJavascriptSource("messages.eng.js", "?"+context.GetBuildNumber( 78484));
         context.AddJavascriptSource("wplogin.js", "?201466953565");
         context.AddJavascriptSource("CapsLock/CapsLockRender.js", "");
         /* End function include_jscripts */
      }

      protected void init_default_properties( )
      {
         lblTextblock1_Internalname = "TEXTBLOCK1";
         lblTextblock2_Internalname = "TEXTBLOCK2";
         edtavUsercid_Internalname = "vUSERCID";
         lblTextblock3_Internalname = "TEXTBLOCK3";
         edtavUsersenha_Internalname = "vUSERSENHA";
         bttButton1_Internalname = "BUTTON1";
         chkavIsremember_Internalname = "vISREMEMBER";
         lblTextblock6_Internalname = "TEXTBLOCK6";
         lblTextblock5_Internalname = "TEXTBLOCK5";
         tblTable2_Internalname = "TABLE2";
         tblTable1_Internalname = "TABLE1";
         Capslock1_Internalname = "CAPSLOCK1";
         Form.Internalname = "FORM";
      }

      public override void initialize_properties( )
      {
         init_default_properties( ) ;
         edtavUsersenha_Jsonclick = "";
         edtavUsercid_Jsonclick = "";
         lblTextblock5_Caption = "CAPS";
         chkavIsremember.Caption = "";
         Capslock1_Attachcaption = "";
         Capslock1_Attachcontrol = "";
         Form.Headerrawhtml = "";
         Form.Background = "";
         Form.Backcolor = (int)(0xFFFFFF);
         Form.Caption = "Entrar";
      }

      public void cleanup( )
      {
         flushBuffer();
         CloseOpenCursors();
         if ( IsMain )
         {
            context.CloseConnections() ;
         }
      }

      protected void CloseOpenCursors( )
      {
      }

      public override void initialize( )
      {
         gxfirstwebparm = "";
         gxfirstwebparm_bkp = "";
         sDynURL = "";
         FormProcess = "";
         GX_FocusControl = "";
         Form = new GXWebForm();
         sPrefix = "";
         sEvt = "";
         EvtGridId = "";
         EvtRowId = "";
         sEvtType = "";
         GXKey = "";
         Gx_date = DateTime.MinValue;
         AV10UserSenha = "";
         AV8Login = "";
         AV11websession = context.GetSession();
         AV12Nivel = "";
         scmdbuf = "";
         H00072_A1UserCID = new int[1] ;
         H00072_A18UserSenhaKey = new String[] {""} ;
         H00072_A17UserSenha = new String[] {""} ;
         H00072_A21UserNivel = new String[] {""} ;
         H00072_A43UserId = new long[1] ;
         A18UserSenhaKey = "";
         A17UserSenha = "";
         A21UserNivel = "";
         sStyleString = "";
         ClassString = "";
         StyleString = "";
         lblTextblock1_Jsonclick = "";
         lblTextblock2_Jsonclick = "";
         TempTags = "";
         lblTextblock3_Jsonclick = "";
         bttButton1_Jsonclick = "";
         lblTextblock6_Jsonclick = "";
         lblTextblock5_Jsonclick = "";
         BackMsgLst = new msglist();
         LclMsgLst = new msglist();
         pr_default = new DataStoreProvider(context, new GeneXus.Programs.wplogin__default(),
            new Object[][] {
                new Object[] {
               H00072_A1UserCID, H00072_A18UserSenhaKey, H00072_A17UserSenha, H00072_A21UserNivel, H00072_A43UserId
               }
            }
         );
         Gx_date = DateTimeUtil.Today( context);
         /* GeneXus formulas. */
         Gx_date = DateTimeUtil.Today( context);
         context.Gx_err = 0;
      }

      private short nGotPars ;
      private short GxWebError ;
      private short initialized ;
      private short gxajaxcallmode ;
      private short wbEnd ;
      private short wbStart ;
      private short nDonePA ;
      private short gxcookieaux ;
      private short AV5CookieLogin ;
      private short AV6CookiePassword ;
      private short nGXWrapped ;
      private int AV9UserCID ;
      private int A1UserCID ;
      private int idxLst ;
      private long AV13UserId ;
      private long A43UserId ;
      private String gxfirstwebparm ;
      private String gxfirstwebparm_bkp ;
      private String sDynURL ;
      private String FormProcess ;
      private String Capslock1_Attachcontrol ;
      private String Capslock1_Attachcaption ;
      private String GX_FocusControl ;
      private String sPrefix ;
      private String sEvt ;
      private String EvtGridId ;
      private String EvtRowId ;
      private String sEvtType ;
      private String GXKey ;
      private String chkavIsremember_Internalname ;
      private String edtavUsercid_Internalname ;
      private String edtavUsersenha_Internalname ;
      private String lblTextblock5_Caption ;
      private String lblTextblock5_Internalname ;
      private String Capslock1_Internalname ;
      private String scmdbuf ;
      private String sStyleString ;
      private String tblTable1_Internalname ;
      private String tblTable2_Internalname ;
      private String ClassString ;
      private String StyleString ;
      private String lblTextblock1_Internalname ;
      private String lblTextblock1_Jsonclick ;
      private String lblTextblock2_Internalname ;
      private String lblTextblock2_Jsonclick ;
      private String TempTags ;
      private String edtavUsercid_Jsonclick ;
      private String lblTextblock3_Internalname ;
      private String lblTextblock3_Jsonclick ;
      private String edtavUsersenha_Jsonclick ;
      private String bttButton1_Internalname ;
      private String bttButton1_Jsonclick ;
      private String lblTextblock6_Internalname ;
      private String lblTextblock6_Jsonclick ;
      private String lblTextblock5_Jsonclick ;
      private DateTime Gx_date ;
      private bool entryPointCalled ;
      private bool wbLoad ;
      private bool Rfr0gs ;
      private bool wbErr ;
      private bool AV7isRemember ;
      private bool returnInSub ;
      private String AV10UserSenha ;
      private String AV8Login ;
      private String AV12Nivel ;
      private String A18UserSenhaKey ;
      private String A17UserSenha ;
      private String A21UserNivel ;
      private IGxSession AV11websession ;
      private GXMasterPage MasterPageObj ;
      private IGxDataStore dsDefault ;
      private GXCheckbox chkavIsremember ;
      private IDataStoreProvider pr_default ;
      private int[] H00072_A1UserCID ;
      private String[] H00072_A18UserSenhaKey ;
      private String[] H00072_A17UserSenha ;
      private String[] H00072_A21UserNivel ;
      private long[] H00072_A43UserId ;
      private msglist BackMsgLst ;
      private msglist LclMsgLst ;
      private GXWebForm Form ;
   }

   public class wplogin__default : DataStoreHelperBase, IDataStoreHelper
   {
      public ICursor[] getCursors( )
      {
         cursorDefinitions();
         return new Cursor[] {
          new ForEachCursor(def[0])
       };
    }

    private static CursorDef[] def;
    private void cursorDefinitions( )
    {
       if ( def == null )
       {
          Object[] prmH00072 ;
          prmH00072 = new Object[] {
          new Object[] {"@AV9UserCID",SqlDbType.Int,6,0}
          } ;
          def= new CursorDef[] {
              new CursorDef("H00072", "SELECT [UserCID], [UserSenhaKey], [UserSenha], [UserNivel], [UserId] FROM [TBLUser] WITH (NOLOCK) WHERE [UserCID] = @AV9UserCID ORDER BY [UserCID] ",false, GxErrorMask.GX_NOMASK | GxErrorMask.GX_MASKLOOPLOCK, false, this,prmH00072,100,0,true,false )
          };
       }
    }

    public void getResults( int cursor ,
                            IFieldGetter rslt ,
                            Object[] buf )
    {
       switch ( cursor )
       {
             case 0 :
                ((int[]) buf[0])[0] = rslt.getInt(1) ;
                ((String[]) buf[1])[0] = rslt.getVarchar(2) ;
                ((String[]) buf[2])[0] = rslt.getVarchar(3) ;
                ((String[]) buf[3])[0] = rslt.getVarchar(4) ;
                ((long[]) buf[4])[0] = rslt.getLong(5) ;
                break;
       }
    }

    public void setParameters( int cursor ,
                               IFieldSetter stmt ,
                               Object[] parms )
    {
       switch ( cursor )
       {
             case 0 :
                stmt.SetParameter(1, (int)parms[0]);
                break;
       }
    }

 }

}
